/*
 * Copyright 2010 Christoph Widulle (christoph.widulle@googlemail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
 * License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */



package com.android1.amarena2d.nodes.particle;

import com.badlogic.gdx.graphics.Color;

public abstract class ParticleEffectConfig {

    public static final float SAME_AS_START = -9999.0F;
    public static final float INFINITE_DURATION = -1.0F;

    public int totalParticles;

    public float duration = INFINITE_DURATION;

    public float emissionRate;

    public float angle = 90;
    public float angleVar = 0;

    public float startSpin;
    public float startSpinVar = 0;

    public float endSpin = SAME_AS_START;
    public float endSpinVar = 0;

    public float startSize;
    public float startSizeVar = 0;

    public float endSize = SAME_AS_START;
    public float endSizeVar = 0;


    public float life;
    public float lifeVar;

    public final Color startColor = new Color(Color.WHITE);
    public final Color startColorVar = new Color(Color.WHITE);
    public final Color endColor = new Color(Color.WHITE);
    public final Color endColorVar = new Color(Color.WHITE);

    public float calcCenter() {
        if (startSize != endSize) {
            if (startSize > endSize)
                return startSize / 2;
            else
                return endSize / 2;
        } else {
            return startSize / 2;
        }
    }

    public boolean isInfiniteDuration() {
        return duration < 0;
    }

    public float calcEmissionRate() {
        if (duration > 0) {
            return totalParticles / duration;
        } else
            return totalParticles / (life + lifeVar);

    }

}